import java.awt.*;
import javax.swing.*;
public class GridBagLayoutDemo extends JFrame{
public GridBagLayoutDemo(){
	   super("GridBagLayout");
	   Container c=getContentPane();
	   //󡢿ռ
	   GridBagLayout gbl=new GridBagLayout();
	   GridBagConstraints gbc=new GridBagConstraints();
	   //ΪܵݴGridBagLayout
	   c.setLayout(gbl);
	   //ťb1,Ϊӿռ
	   JButton b1=new JButton("button1");
	   gbc.fill=GridBagConstraints.BOTH;
	   gbc.weightx=1.0;
	   gbc.weighty=1.0;
	   gbl.setConstraints(b1,gbc);
	   c.add(b1);
	   //ťb2,Ϊӿռ
	   JButton b2=new JButton("button2");
	   gbc.gridwidth=GridBagConstraints.REMAINDER;
	   gbl.setConstraints(b2,gbc);
	   c.add(b2);
	   //ťb3,Ϊӿռ
	   JButton b3=new JButton("button3");
	   gbc.weightx=0.0;
	   gbl.setConstraints(b3,gbc);
	   c.add(b3);
	   //ťb4,Ϊӿռ
	   JButton b4=new JButton("button4");
	   gbc.gridwidth=1;
	   gbc.gridheight=2;
	   gbl.setConstraints(b4,gbc);
	   c.add(b4);
	   //ťb5,Ϊӿռ
	   JButton b5=new JButton("button5");
	   gbc.gridwidth=GridBagConstraints.REMAINDER;
	   gbc.gridheight=1;
	   gbl.setConstraints(b5,gbc);
	   c.add(b5);
	   //ťb6,Ϊӿռ
	   JButton b6=new JButton("button6");
	   gbc.gridwidth=GridBagConstraints.REMAINDER;
	   gbc.gridheight=1;
	   gbl.setConstraints(b6,gbc);
	   c.add(b6);
        }
        public static void main(String args[]){
    	   JFrame frame=new GridBagLayoutDemo();
                frame.setSize(200,150);
    	   frame.setVisible(true);
        }
}
